package edu.hhu.basic.table;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class BTableDao {
	
	public List getHaeder(String table){
    	String sql="select * from data_dictionary WHERE tablename='"+table.toUpperCase()+"'";
    	List<Record> data = Db.use("mysql").find(sql);
    	List jsonList = new ArrayList();
		int i = 0;
		for (Record record : data) {
			jsonList.add(record.getColumns());
			i++;
		}
		String json = JSON.toJSONString(jsonList);
//		System.out.println(i + "||" + json);
		
		return jsonList;

    }
public List	getFields(String table){
	String sql="select fieldcode from data_dictionary WHERE tablename='"+table.toUpperCase()+"'";
	List<Record> data = Db.use("mysql").find(sql);
	/*List jsonList = new ArrayList();
	int i = 0;
	for (Record record : data) {
		jsonList.add(record.getColumns());
		i++;
	}
	String json = JSON.toJSONString(jsonList);*/
//	System.out.println(i + "||" + json);
	return data;
  }

}
